package com.yhsimon.reflection;

public class Test04 {
    static {
        System.out.println("Main类被加载");
    }

    public static void main(String[] args) throws ClassNotFoundException {
        //1.主动引用
        //Son son=new Son();

        //反射也会产生主动引用
        //Class.forName("com.yhsimon.reflection.Son");


        //不会产生类的引用的方法
        //System.out.println(Son.a);   //1.引用父类的静态变量
        //Son[] sons=new Son[5];       //2.通过数组定义类引用
        System.out.println(Son.M);     //3.引用常量





    }
}

class Father{
    static int a=5;
    static {
        System.out.println("父类被加载");
    }
}

class Son extends Father{
    static {
        System.out.println("子类被加载");
        b=555;
    }
    static int b=55;
    static final int M=1;
}